//
//  FreeAdviViewController.m
//  WE
//
//  Created by iMacOne on 15/11/21.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "FreeAdviViewController.h"
#import "Size.h"
#import "ToolUtil.h"
@interface FreeAdviViewController ()
@property (nonatomic, strong)UITextView * textView;
@property (nonatomic, strong)UILabel * placeholderLabel;
@end

@implementation FreeAdviViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self creatView];
}

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    
}

- (void)creatView
{
//    float y = [ToolUtil createLine:65 superView:self.view lift:0 width:WindowWidth hight:1 color:[UIColor grayColor]];
    UILabel * lbl = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 50, 20)];
    lbl.text = @"咨询人";
    lbl.font = FONT(14);
    
    UIImageView * aImageV = [[UIImageView alloc] initWithFrame:CGRectMake(WindowWidth - 30, 10, 20, 20)];
//    aImageV.image = [UIImage imageNamed:@"you"];
    
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 64, WindowWidth, 40);
    [btn addTarget:self action:@selector(doClickBtn:) forControlEvents:UIControlEventTouchUpInside];
    btn.tag = 100;
    [btn addSubview:aImageV];
    [btn addSubview:lbl];
    
    [self.view addSubview:btn];
    
    float y = [ToolUtil createLine:CGRectGetMaxY(btn.frame) superView:self.view lift:0 width:WindowWidth hight:1 color:GRAYCOLOR];
    
    self.textView = [[UITextView alloc] initWithFrame:CGRectMake(margin_10, y, WindowWidth - 2 * margin_10, 120)];
    _textView.delegate = self;
//    _textView.backgroundColor = [UIColor grayColor];
    self.placeholderLabel = [[UILabel alloc] initWithFrame:CGRectMake(3, 2, _textView.frame.size.width, 40)];
    _placeholderLabel.text = @"请详细描述你的病情, 症状, 治疗经过以及想要获得我们可以提供给你的帮助";
    _placeholderLabel.font = FONT(14);
    _placeholderLabel.numberOfLines = 0;
    _placeholderLabel.textColor = [UIColor grayColor];
    _placeholderLabel.enabled = NO;
    [_textView addSubview:_placeholderLabel];
    [self.view addSubview:_textView];
    
    [ToolUtil createLine:CGRectGetMaxY(_textView.frame) superView:self.view lift:0 width:WindowWidth hight:1 color:GRAYCOLOR];
    UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 10, 20, 24)];
    
    UIImageView * imageV = [[UIImageView alloc] initWithFrame:CGRectMake((20 - 24 * 0.56)/2, 0, 24 * 0.56, 24)];
    imageV.image = [UIImage imageNamed:@"back"];
    [backButton addSubview:imageV];
    
    [backButton addTarget:self action:@selector(doClickBtn:) forControlEvents:UIControlEventTouchUpInside];
    backButton.tag = 101;
    
//    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
//    self.navigationItem.leftBarButtonItem = backItem;
    self.navigationItem.title = @"免费咨询";
    
    UIButton * rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 10, 30, 24)];
    rightBtn.titleLabel.font = FONT(14);
    [rightBtn setTitle:@"提问" forState:UIControlStateNormal];
    [rightBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    rightBtn.tag = 102;
//    UIImageView * imageV = [[UIImageView alloc] initWithFrame:CGRectMake((20 - 24 * 0.56)/2, 0, 24 * 0.56, 24)];
//    imageV.image = [UIImage imageNamed:@"back"];
//    [backButton addSubview:imageV];
    [backButton addTarget:self action:@selector(doClickBtn:) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];

    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.textView resignFirstResponder];
}
- (void)doClickBtn:(UIButton *)btn
{
    if (btn.tag == 101) {
        [self.navigationController popViewControllerAnimated:YES];
    }
    
}
- (void)textViewDidChange:(UITextView *)textView;

{
    if ([ToolUtil isBlank:textView.text]) {
        self.placeholderLabel.hidden = NO;
    }else {
        self.placeholderLabel.hidden = YES;
    }
    
}

@end
